package com.zmn.mcc.admin.controller.staff.staffcontract;


import com.zmn.mcc.model.entity.staff.McStaff;
import com.zmn.mcc.model.entity.staff.staffcontract.StaffContract;
import com.zmn.mcc.services.interfaces.staff.staffcontract.StaffContractService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * 员工合同信息基础查询Controller
 *
 * @author tanghongjun
 * @since 2020-05-14 11:15:18
 */
@RestController
@RequestMapping("/staff/staffcontract/")
public class StaffContractListController extends StaffContractBaseController {

    private Logger logger = LoggerFactory.getLogger(StaffContractListController.class);

    @Resource
    private StaffContractService staffContractService;

    /**
     * 信息
     */
    @RequestMapping("/addEditView")
//    @RequiresPermissions("staff/staffcontract/addEditView.action")
    public ModelAndView addEditView(@RequestParam(value = "staffId", defaultValue = "0") Integer staffId) {

        McStaff staff = staffService.findByKey(staffId);
        StaffContract staffContract = staffContractService.findByStaffId(staffId);
        if (Objects.isNull(staffContract)) {
            staffContract = new StaffContract();
            staffContract.setStaffId(staffId);
        }

        ModelAndView mav = new ModelAndView("staff/staffcontract/detail");
        mav.addObject("staffContract", staffContract);

        mav.addObject("obj", staff);
        mav.addObject("flag", 3);
        return mav;
    }

}
